package kt.hkit.androidcomplete01.chapter09;

import kr.hkit.androidcomplete01.R;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.widget.TextView;
import android.widget.Toast;

public class OptionMenuXml extends Activity {
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);

		TextView tv = new TextView(this);
		tv.setText("메뉴 키를 누르세요");
		setContentView(tv);
	}
	
	public boolean onCreateOptionsMenu(Menu menu) {
		MenuInflater inflater = getMenuInflater();
		inflater.inflate(R.menu.menu, menu);
		
		return true;
	}
	
	public boolean onOptionsItemSelected(MenuItem item) {
		String text = null;
		
		switch(item.getItemId()){
		case R.id.jjajang:
			text = "짜장은 달콤해";
			break;
		case R.id.jjambbong:
			text = "짬뽕은 매워";
			break;
		case R.id.udong:
			text = "우동은 시원해";
			break;
		case R.id.mandoo:
			startActivity(new Intent(this, MenuTest.class));
			break;
		}
		
		Toast.makeText(this, text, Toast.LENGTH_SHORT).show();
		
		return true;
	}
}
